const path = require('path')
const nodeExternals = require('webpack-node-externals')

// 导出配置对象
module.exports = {
  target: "node", // 因为当前代码属于node代码，它需要再node环境中运行
  mode: "development",
  entry: "./server.js",
  output: {
    path: path.resolve(__dirname, 'build'), // 打包文件路径，需要绝对路径
    filename: "server.js", // 打包文件名字
  },
  // 指定babel
  module: {
    // 打包规则
    rules: [{
      test: /\.js$/,
      exclude: /node_modules/,
      use: {
        loader: "babel-loader"
      }
    }]
  },
  // 告诉webpack不要打包node_modules下的内容
  externals: [nodeExternals()]
}